package de.luisoft.ui;

import com.vaadin.Application;
import com.vaadin.terminal.ClassResource;
import com.vaadin.ui.Embedded;
import com.vaadin.ui.Form;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;

import de.luisoft.ui.model.ProjectModelContainer;
import de.luisoft.ui.view.DescriptionPanel;
import de.luisoft.ui.view.FormPanel;
import de.luisoft.ui.view.TwinPanel;

public class LuiApplication extends Application {

	private static final long serialVersionUID = 7122881448433964262L;

	@Override
	public void init() {
		setMainWindow(new Window("Projektauswahl"));

		VerticalLayout picture = getPicture();
		ProjectModelContainer p = new ProjectModelContainer();
		DescriptionPanel txt = new DescriptionPanel(p);
		TwinPanel t = new TwinPanel(p);
		Form formLayout = new FormPanel(t);

		VerticalLayout vl = new VerticalLayout();
		vl.setWidth("480px");
		picture.setMargin(false, false, true, false);
		vl.addComponent(picture);
		vl.addComponent(t);

		HorizontalLayout hl = new HorizontalLayout();
		hl.addComponent(vl);
		vl.setMargin(false, true, false, false);
		hl.addComponent(formLayout);

		VerticalLayout vl1 = new VerticalLayout();
		hl.setMargin(false, false, true, false);
		vl1.addComponent(hl);
		vl1.addComponent(txt);
		vl1.addComponent(new Label("by Lui"));
		getMainWindow().addComponent(vl1);
	}

	private VerticalLayout getPicture() {
		final VerticalLayout l = new VerticalLayout();

		Embedded e = new Embedded(null, new ClassResource("header_picture.png",
				this));
		e.setType(Embedded.TYPE_IMAGE);
		e.setWidth("469px");
		e.setHeight("110px");
		l.addComponent(e);

		return l;
	}

}
